home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
011
/
curdir.lqr
/
CURDIR.ASM
next >
Wrap
Assembly Source File
|
1985-06-03
|
3KB
|
111 lines
INCLUDE MACROS.ASM
BEGINCOM DIRSAV
JMP DIRS100
DIRSTR LABEL BYTE
;
; DISK RECORD
;
RECBEGIN EQU $
DRIVENO DB 0
DRIVE DB 0
DB ':\'
PATH DB 64 DUP (?)
LRECL EQU ($-RECBEGIN)
;
;
;
SAVEFILE DB 'C:\DIR%.SAV',0
;
;
;
DIRS100:
MOV AX,CS
MOV DS,AX
;
; CHECK PARM
;
MOV BX,80H ;PARAMETER SAVE AREA
MOV CL,BYTE PTR [BX] ;GET PARAMETER CHARACTER COUNT
OR CL,CL ;ANY PARM
JZ DIRS140 ;NO-ISSUE ERROR
INC BX ;POINT TO PARM AREA
DIRS120: MOV AL,BYTE PTR [BX] ;GET A CHARACTER
CMP AL, '/' ;PARM FLAG?
JE DIRS160 ;YES-NEXT BYTE IS PARM
INC BX ;ELSE, KEEP CHECKING
LOOP DIRS120
DIRS140: JMP DIRS900 ;JUMP TO INVLD PARM ERROR
DIRS160: MOV AL,BYTE PTR [BX+1] ;GET PARM
CMP AL,'R' ;IS IT RESTORE?
JE DIRS300 ;YES-THEN DO IT
CMP AL,'r' ;IS IT RESTORE?
JE DIRS300 ;YES-THEN DO IT
CMP AL,'S' ;IS IT SAVE
JE DIRS200 ;YES-SAVE DIRECTORY
CMP AL,'s' ;IS IT SAVE
JNE DIRS140 ;NO-GO TO INVALID PARM MESSAGE
;
; SAVE CURRENT DIRECTORY/DRIVE TO DISK
;
DIRS200:
@DOS 19H ;GET CURRENT DISK IN AL
MOV DRIVENO,AL ;DRIVE NUMBER = 0-3
MOV DL,AL ;SAVE NUMBER FOR GETTING DIR
ADD AL,'A' ;GET DRIVE IN CHARACTER FORMAT
MOV DRIVE,AL ;SAVE CHARACTER DRIVE NUMBER
;
INC DL ;GET DRIVE # (1-4)
MOV SI,OFFSET PATH ;CURRENT PATH SAVE AREA
@DOS 47H ;GET CURRENT DIRECTORY
MOV DX,OFFSET SAVEFILE ;POINT TO TEMP FILENAME
SUB CX,CX ;NO SPECIAL ATTRIBUTES
@DOS 3CH ;CREATE THE FILE, OPEN FOR R/W
JC DIRS290 ;CREATE FAIL - DISK ERR
MOV BX,AX ;COPY FILE HANDLE
MOV CX,LRECL ;BYTES TO SEND
MOV DX,OFFSET RECBEGIN ;START OF RECORD POINTER
@DOS 40H ;WRITE THE FILE
JC DIRS290 ;JMP IF ERR
CMP AX,CX ;CORRECT WRITE COUNT?
JNE DIRS290 ;NO-DISK ERR
@DOS 3EH ;OTHERWISE-CLOSE FILE
JMP DIRS990 ;AND EXIT
DIRS290: JMP DIRS920
;
; RESTORE SAVED DIRECTORY FROM DISK
;
DIRS300:
MOV DX,OFFSET SAVEFILE ;POINT TO SAVE FILENAME
SUB AX,AX ;OPEN FOR READ
@DOS 3DH ;OPEN THE FILE
JC DIRS910 ;CY=NO FILE
MOV BX,AX ;SAVE HANDLE
MOV CX,LRECL ;GET RECORD LENGTH
MOV DX,OFFSET RECBEGIN ;POINT TO DATA AREA
@DOS 3FH ;READ THE DATA
JC DIRS930 ;JMP TO ERR IF CANT READ
@DOS 3EH ;CLOSE THE FILE
MOV DX,OFFSET SAVEFILE ;POINT TO SAVE FILENAME
@DOS 41H ;DELETE THE FILE
MOV DL,DRIVENO ;GET DISK NUMBER
@DOS 0EH ;SELECT DISK
MOV DX,OFFSET DRIVE ;POINT TO FULL PATH
@DOS 3BH ;SWITCH TO SAVED DIR
JC DIRS940 ;MSG IF ERR
JMP DIRS990 ;ELSE-DONE
;
; ERRORS
;
DIRS910: @MSG 'NOTHING TO RESTORE'
JMP DIRS990
DIRS930: @MSG 'DISK READ ERROR'
JMP DIRS990
DIRS920: @MSG 'DISK WRITE ERROR'
JMP DIRS990
DIRS940: @MSG 'CANT SEL'
JMP DIRS990
DIRS900: @MSG 'INVALID PARM MUST BE /S OR /R'
DIRS990: @DOS 0 ;EXIT
ENDCOM DIRSAV